
function ajax(url) {
    return new Promise(function(resolve, reject){
        const xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.send();
        xhr.onloadend = resolve(xhr.responseText);
        xhr.onerror = reject(new Error('some error'));
    });
}

